<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>用户管理 - 转炉终点预测系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <link rel="stylesheet" href="styles/unified.css">
    <link rel="stylesheet" href="styles/components.css">
    <link rel="stylesheet" href="styles/sidebar-theme.css">
    <link rel="stylesheet" href="styles/scale-fix.css">
    <link rel="stylesheet" href="styles/modal-dialog.css">
</head>
<body>
    <!-- 侧边栏 -->
    <div class="sidebar">
        <div class="sidebar-header">
            <div class="sidebar-logo">
                <i class="fas fa-industry"></i>
            </div>
            <div class="sidebar-title">转炉终点预测系统</div>
        </div>
        <div class="sidebar-menu">
            <div class="sidebar-menu-title">主导航</div>
            <ul>
                <li><a href="index.html"><i class="fas fa-home"></i>首页</a></li>
                
                <li><a href="production-monitor.html"><i class="fas fa-chart-line"></i>生产监控</a></li>
                <li><a href="history-data.html"><i class="fas fa-history"></i>历史数据</a></li>
                <li><a href="quality-analysis.html"><i class="fas fa-flask"></i>质量分析</a></li>
            </ul>
            
            <div class="sidebar-menu-title">模型管理</div>
            <ul>
                <li><a href="model-details.html"><i class="fas fa-brain"></i>模型详情</a></li>
                <li><a href="model-config.html"><i class="fas fa-cogs"></i>模型配置</a></li>
                <li><a href="model-performance.html"><i class="fas fa-chart-bar"></i>模型性能</a></li>
                <li><a href="model-update.html"><i class="fas fa-sync-alt"></i>模型更新</a></li>
            </ul>
            
            <div class="sidebar-menu-title">系统设置</div>
            <ul>
                <li><a href="system-settings.html"><i class="fas fa-cog"></i>系统设置</a></li>
                <li><a href="user-management.html" class="active"><i class="fas fa-user-cog"></i>用户管理</a></li>
                <li><a href="alert-settings.html"><i class="fas fa-bell"></i>预警设置</a></li>
                <li><a href="data-management.html"><i class="fas fa-database"></i>数据管理</a></li>
                <li><a href="online-analysis.html"><i class="fas fa-chart-bar"></i>在线分析</a></li>
            </ul>
        </div>
        <div class="sidebar-footer">
            <i class="fas fa-info-circle"></i>
            <span>系统版本：v2.5.3</span>
        </div>
    </div>

    <!-- 侧边栏遮罩层 -->
    <div class="sidebar-overlay"></div>

    <div class="container">
        <div class="header">
            <div class="header-left">
                <div>
                    <div class="title">用户管理</div>
                    <div class="subtitle">管理系统用户、权限和角色配置</div>
                </div>
            </div>
            <div class="header-right">
                <div class="header-icon">
                    <i class="fas fa-search"></i>
                </div>
                <div class="header-icon">
                    <i class="fas fa-bell"></i>
                    <span class="notification-badge">3</span>
                </div>
                <div class="dropdown">
                    <div class="user-dropdown dropdown-trigger">
                        <img src="https://randomuser.me/api/portraits/men/32.jpg" alt="用户头像" class="user-avatar">
                        <span class="user-name">管理员</span>
                        <i class="fas fa-chevron-down"></i>
                    </div>
                    <div class="dropdown-menu">
                        <a href="#" class="dropdown-item">
                            <i class="fas fa-user"></i>
                            <span>个人资料</span>
                        </a>
                        <a href="#" class="dropdown-item">
                            <i class="fas fa-cog"></i>
                            <span>账号设置</span>
                        </a>
                        <a href="#" class="dropdown-item">
                            <i class="fas fa-question-circle"></i>
                            <span>帮助中心</span>
                        </a>
                        <a href="login.html" class="dropdown-item">
                            <i class="fas fa-sign-out-alt"></i>
                            <span>退出登录</span>
                        </a>
                    </div>
                </div>
            </div>
        </div>

        <div class="content-wrapper">
            <!-- 用户管理卡片 -->
            <div class="card">
                <div class="card-header">
                    <div class="card-title">
                        <i class="fas fa-users"></i>
                        用户列表
                    </div>
                    <div class="card-actions">
                        <button class="btn btn-primary">
                            <i class="fas fa-user-plus"></i>
                            添加用户
                        </button>
                        <div class="dropdown">
                            <button class="btn btn-secondary dropdown-trigger">
                                <i class="fas fa-filter"></i>
                                筛选
                            </button>
                            <div class="dropdown-menu">
                                <a href="#" class="dropdown-item">所有用户</a>
                                <a href="#" class="dropdown-item">管理员</a>
                                <a href="#" class="dropdown-item">工程师</a>
                                <a href="#" class="dropdown-item">操作员</a>
                                <a href="#" class="dropdown-item">访客</a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="card-content">
                    <div class="table-responsive">
                        <table>
                            <thead>
                                <tr>
                                    <th style="width: 50px;">#</th>
                                    <th style="width: 80px;">头像</th>
                                    <th>用户名</th>
                                    <th>角色</th>
                                    <th>部门</th>
                                    <th>状态</th>
                                    <th>最后登录</th>
                                    <th style="width: 150px;">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>1</td>
                                    <td>
                                        <img src="https://randomuser.me/api/portraits/men/32.jpg" alt="用户头像" class="user-table-avatar">
                                    </td>
                                    <td>admin</td>
                                    <td>系统管理员</td>
                                    <td>信息技术部</td>
                                    <td><span class="status-badge active">活跃</span></td>
                                    <td>2023-11-28 08:32</td>
                                    <td>
                                        <div class="table-actions">
                                            <button class="action-btn" title="编辑">
                                                <i class="fas fa-edit"></i>
                                            </button>
                                            <button class="action-btn" title="权限">
                                                <i class="fas fa-key"></i>
                                            </button>
                                            <button class="action-btn" title="删除">
                                                <i class="fas fa-trash-alt"></i>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>2</td>
                                    <td>
                                        <img src="https://randomuser.me/api/portraits/women/44.jpg" alt="用户头像" class="user-table-avatar">
                                    </td>
                                    <td>engineer1</td>
                                    <td>工艺工程师</td>
                                    <td>生产技术部</td>
                                    <td><span class="status-badge active">活跃</span></td>
                                    <td>2023-11-27 16:45</td>
                                    <td>
                                        <div class="table-actions">
                                            <button class="action-btn" title="编辑">
                                                <i class="fas fa-edit"></i>
                                            </button>
                                            <button class="action-btn" title="权限">
                                                <i class="fas fa-key"></i>
                                            </button>
                                            <button class="action-btn" title="删除">
                                                <i class="fas fa-trash-alt"></i>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>3</td>
                                    <td>
                                        <img src="https://randomuser.me/api/portraits/men/67.jpg" alt="用户头像" class="user-table-avatar">
                                    </td>
                                    <td>operator1</td>
                                    <td>操作员</td>
                                    <td>生产部</td>
                                    <td><span class="status-badge active">活跃</span></td>
                                    <td>2023-11-28 06:20</td>
                                    <td>
                                        <div class="table-actions">
                                            <button class="action-btn" title="编辑">
                                                <i class="fas fa-edit"></i>
                                            </button>
                                            <button class="action-btn" title="权限">
                                                <i class="fas fa-key"></i>
                                            </button>
                                            <button class="action-btn" title="删除">
                                                <i class="fas fa-trash-alt"></i>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>4</td>
                                    <td>
                                        <img src="https://randomuser.me/api/portraits/women/28.jpg" alt="用户头像" class="user-table-avatar">
                                    </td>
                                    <td>analyst1</td>
                                    <td>数据分析师</td>
                                    <td>质量管理部</td>
                                    <td><span class="status-badge inactive">离线</span></td>
                                    <td>2023-11-26 14:15</td>
                                    <td>
                                        <div class="table-actions">
                                            <button class="action-btn" title="编辑">
                                                <i class="fas fa-edit"></i>
                                            </button>
                                            <button class="action-btn" title="权限">
                                                <i class="fas fa-key"></i>
                                            </button>
                                            <button class="action-btn" title="删除">
                                                <i class="fas fa-trash-alt"></i>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>5</td>
                                    <td>
                                        <img src="https://randomuser.me/api/portraits/men/54.jpg" alt="用户头像" class="user-table-avatar">
                                    </td>
                                    <td>manager1</td>
                                    <td>部门经理</td>
                                    <td>生产管理部</td>
                                    <td><span class="status-badge active">活跃</span></td>
                                    <td>2023-11-27 10:45</td>
                                    <td>
                                        <div class="table-actions">
                                            <button class="action-btn" title="编辑">
                                                <i class="fas fa-edit"></i>
                                            </button>
                                            <button class="action-btn" title="权限">
                                                <i class="fas fa-key"></i>
                                            </button>
                                            <button class="action-btn" title="删除">
                                                <i class="fas fa-trash-alt"></i>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    
                    <div class="pagination">
                        <button class="btn btn-icon pagination-btn" disabled>
                            <i class="fas fa-chevron-left"></i>
                        </button>
                        <button class="btn pagination-btn active">1</button>
                        <button class="btn pagination-btn">2</button>
                        <button class="btn pagination-btn">3</button>
                        <button class="btn pagination-btn">...</button>
                        <button class="btn pagination-btn">8</button>
                        <button class="btn btn-icon pagination-btn">
                            <i class="fas fa-chevron-right"></i>
                        </button>
                    </div>
                </div>
            </div>
            
            <!-- 角色管理卡片 -->
            <div class="card">
                <div class="card-header">
                    <div class="card-title">
                        <i class="fas fa-user-tag"></i>
                        角色管理
                    </div>
                    <button class="btn btn-primary">
                        <i class="fas fa-plus"></i>
                        添加角色
                    </button>
                </div>
                <div class="card-content">
                    <div class="table-responsive">
                        <table>
                            <thead>
                                <tr>
                                    <th style="width: 50px;">#</th>
                                    <th>角色名称</th>
                                    <th>描述</th>
                                    <th>用户数</th>
                                    <th>创建时间</th>
                                    <th style="width: 150px;">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>1</td>
                                    <td>系统管理员</td>
                                    <td>具有系统所有操作权限</td>
                                    <td>1</td>
                                    <td>2023-01-01</td>
                                    <td>
                                        <div class="table-actions">
                                            <button class="action-btn" title="编辑">
                                                <i class="fas fa-edit"></i>
                                            </button>
                                            <button class="action-btn" title="权限">
                                                <i class="fas fa-key"></i>
                                            </button>
                                            <button class="action-btn" title="删除" disabled>
                                                <i class="fas fa-trash-alt"></i>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>2</td>
                                    <td>工艺工程师</td>
                                    <td>负责工艺参数配置和模型调优</td>
                                    <td>5</td>
                                    <td>2023-01-15</td>
                                    <td>
                                        <div class="table-actions">
                                            <button class="action-btn" title="编辑">
                                                <i class="fas fa-edit"></i>
                                            </button>
                                            <button class="action-btn" title="权限">
                                                <i class="fas fa-key"></i>
                                            </button>
                                            <button class="action-btn" title="删除">
                                                <i class="fas fa-trash-alt"></i>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>3</td>
                                    <td>操作员</td>
                                    <td>负责日常生产操作和监控</td>
                                    <td>12</td>
                                    <td>2023-01-20</td>
                                    <td>
                                        <div class="table-actions">
                                            <button class="action-btn" title="编辑">
                                                <i class="fas fa-edit"></i>
                                            </button>
                                            <button class="action-btn" title="权限">
                                                <i class="fas fa-key"></i>
                                            </button>
                                            <button class="action-btn" title="删除">
                                                <i class="fas fa-trash-alt"></i>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>4</td>
                                    <td>数据分析师</td>
                                    <td>负责数据分析和报表生成</td>
                                    <td>3</td>
                                    <td>2023-02-05</td>
                                    <td>
                                        <div class="table-actions">
                                            <button class="action-btn" title="编辑">
                                                <i class="fas fa-edit"></i>
                                            </button>
                                            <button class="action-btn" title="权限">
                                                <i class="fas fa-key"></i>
                                            </button>
                                            <button class="action-btn" title="删除">
                                                <i class="fas fa-trash-alt"></i>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="scripts/unified.js"></script>
    <script src="scripts/modal-dialog.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 初始化下拉菜单
            initDropdowns();
            
            // 初始化状态徽章颜色
            const statusBadges = document.querySelectorAll('.status-badge');
            statusBadges.forEach(badge => {
                if (badge.classList.contains('active')) {
                    badge.style.backgroundColor = 'rgba(76, 175, 80, 0.1)';
                    badge.style.color = '#4caf50';
                } else if (badge.classList.contains('inactive')) {
                    badge.style.backgroundColor = 'rgba(158, 158, 158, 0.1)';
                    badge.style.color = '#9e9e9e';
                }
            });
            
            // 为添加用户按钮添加点击事件
            const addUserBtn = document.querySelector('.card-actions .btn-primary');
            if (addUserBtn) {
                addUserBtn.addEventListener('click', function() {
                    showNotification('正在打开添加用户表单...', 'info');
                    setTimeout(() => {
                        showDialog('添加新用户', `
                            <div class="form-group">
                                <label>用户名</label>
                                <input type="text" class="form-control" placeholder="请输入用户名">
                            </div>
                            <div class="form-group">
                                <label>密码</label>
                                <input type="password" class="form-control" placeholder="请输入密码">
                            </div>
                            <div class="form-group">
                                <label>角色</label>
                                <select class="form-control">
                                    <option>请选择角色</option>
                                    <option>系统管理员</option>
                                    <option>工艺工程师</option>
                                    <option>操作员</option>
                                    <option>数据分析师</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label>部门</label>
                                <select class="form-control">
                                    <option>请选择部门</option>
                                    <option>信息技术部</option>
                                    <option>生产技术部</option>
                                    <option>生产部</option>
                                    <option>质量管理部</option>
                                    <option>生产管理部</option>
                                </select>
                            </div>
                        `);
                    }, 500);
                });
            }
            
            // 为添加角色按钮添加点击事件
            const addRoleBtn = document.querySelector('.card-header .btn-primary');
            if (addRoleBtn && addRoleBtn.textContent.includes('添加角色')) {
                addRoleBtn.addEventListener('click', function() {
                    showNotification('正在打开添加角色表单...', 'info');
                    setTimeout(() => {
                        showDialog('添加新角色', `
                            <div class="form-group">
                                <label>角色名称</label>
                                <input type="text" class="form-control" placeholder="请输入角色名称">
                            </div>
                            <div class="form-group">
                                <label>角色描述</label>
                                <textarea class="form-control" placeholder="请输入角色描述"></textarea>
                            </div>
                            <div class="form-group">
                                <label>权限设置</label>
                                <div class="checkbox-group">
                                    <div class="checkbox-item">
                                        <input type="checkbox" id="perm1" checked>
                                        <label for="perm1">仪表盘查看</label>
                                    </div>
                                    <div class="checkbox-item">
                                        <input type="checkbox" id="perm2" checked>
                                        <label for="perm2">数据查询</label>
                                    </div>
                                    <div class="checkbox-item">
                                        <input type="checkbox" id="perm3">
                                        <label for="perm3">模型配置</label>
                                    </div>
                                    <div class="checkbox-item">
                                        <input type="checkbox" id="perm4">
                                        <label for="perm4">系统设置</label>
                                    </div>
                                    <div class="checkbox-item">
                                        <input type="checkbox" id="perm5">
                                        <label for="perm5">用户管理</label>
                                    </div>
                                </div>
                            </div>
                        `);
                    }, 500);
                });
            }
            
            // 为筛选下拉菜单项添加点击事件
            const filterItems = document.querySelectorAll('.dropdown-menu .dropdown-item');
            filterItems.forEach(item => {
                item.addEventListener('click', function(e) {
                    e.preventDefault();
                    const filterText = this.textContent.trim();
                    showNotification(`已筛选：${filterText}`, 'success');
                    
                    // 关闭下拉菜单
                    this.closest('.dropdown-menu').classList.remove('show');
                });
            });
            
            // 为分页按钮添加点击事件
            const paginationBtns = document.querySelectorAll('.pagination-btn');
            paginationBtns.forEach(btn => {
                if (!btn.disabled) {
                    btn.addEventListener('click', function() {
                        // 移除所有活跃状态
                        paginationBtns.forEach(b => b.classList.remove('active'));
                        
                        // 添加当前活跃状态
                        this.classList.add('active');
                        
                        const pageNum = this.textContent.trim();
                        if (pageNum && !isNaN(pageNum)) {
                            showNotification(`已切换到第${pageNum}页`, 'info');
                        } else if (this.querySelector('.fa-chevron-left')) {
                            showNotification('已切换到上一页', 'info');
                        } else if (this.querySelector('.fa-chevron-right')) {
                            showNotification('已切换到下一页', 'info');
                        }
                    });
                }
            });
            
            // 为操作按钮添加悬停效果
            const actionBtns = document.querySelectorAll('.action-btn');
            actionBtns.forEach(btn => {
                if (!btn.disabled) {
                    btn.addEventListener('mouseenter', () => {
                        btn.style.backgroundColor = 'rgba(0, 0, 0, 0.05)';
                    });
                    
                    btn.addEventListener('mouseleave', () => {
                        btn.style.backgroundColor = '';
                    });
                    
                    // 添加点击事件
                    btn.addEventListener('click', function() {
                        const action = this.getAttribute('title');
                        const isUserTable = this.closest('tbody').querySelector('td:nth-child(3)') !== null;
                        
                        let itemName = '';
                        if (isUserTable) {
                            itemName = this.closest('tr').querySelector('td:nth-child(3)').textContent;
                        } else {
                            itemName = this.closest('tr').querySelector('td:nth-child(2)').textContent;
                        }
                        
                        if (action === '编辑') {
                            showNotification(`正在编辑${itemName}...`, 'info');
                            if (isUserTable) {
                                // 编辑用户
                                setTimeout(() => {
                                    showDialog(`编辑用户: ${itemName}`, `
                                        <div class="form-group">
                                            <label>用户名</label>
                                            <input type="text" class="form-control" value="${itemName}">
                                        </div>
                                        <div class="form-group">
                                            <label>角色</label>
                                            <select class="form-control">
                                                <option>系统管理员</option>
                                                <option>工艺工程师</option>
                                                <option>操作员</option>
                                                <option>数据分析师</option>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label>部门</label>
                                            <select class="form-control">
                                                <option>信息技术部</option>
                                                <option>生产技术部</option>
                                                <option>生产部</option>
                                                <option>质量管理部</option>
                                                <option>生产管理部</option>
                                            </select>
                                        </div>
                                    `);
                                }, 500);
                            } else {
                                // 编辑角色
                                setTimeout(() => {
                                    showDialog(`编辑角色: ${itemName}`, `
                                        <div class="form-group">
                                            <label>角色名称</label>
                                            <input type="text" class="form-control" value="${itemName}">
                                        </div>
                                        <div class="form-group">
                                            <label>角色描述</label>
                                            <textarea class="form-control">${this.closest('tr').querySelector('td:nth-child(3)').textContent}</textarea>
                                        </div>
                                        <div class="form-group">
                                            <label>权限设置</label>
                                            <div class="checkbox-group">
                                                <div class="checkbox-item">
                                                    <input type="checkbox" id="edit_perm1" checked>
                                                    <label for="edit_perm1">仪表盘查看</label>
                                                </div>
                                                <div class="checkbox-item">
                                                    <input type="checkbox" id="edit_perm2" checked>
                                                    <label for="edit_perm2">数据查询</label>
                                                </div>
                                                <div class="checkbox-item">
                                                    <input type="checkbox" id="edit_perm3">
                                                    <label for="edit_perm3">模型配置</label>
                                                </div>
                                            </div>
                                        </div>
                                    `);
                                }, 500);
                            }
                        } else if (action === '权限') {
                            showNotification(`正在设置${itemName}的权限...`, 'info');
                            setTimeout(() => {
                                showDialog(`权限设置: ${itemName}`, `
                                    <div class="permission-list">
                                        <div class="permission-group">
                                            <div class="permission-group-title">仪表盘</div>
                                            <div class="checkbox-group">
                                                <div class="checkbox-item">
                                                    <input type="checkbox" id="dash_view" checked>
                                                    <label for="dash_view">查看仪表盘</label>
                                                </div>
                                                <div class="checkbox-item">
                                                    <input type="checkbox" id="dash_export" checked>
                                                    <label for="dash_export">导出数据</label>
                                                </div>
                                            </div>
                                        </div>
                                        
                                        <div class="permission-group">
                                            <div class="permission-group-title">模型管理</div>
                                            <div class="checkbox-group">
                                                <div class="checkbox-item">
                                                    <input type="checkbox" id="model_view" checked>
                                                    <label for="model_view">查看模型</label>
                                                </div>
                                                <div class="checkbox-item">
                                                    <input type="checkbox" id="model_edit">
                                                    <label for="model_edit">编辑模型</label>
                                                </div>
                                                <div class="checkbox-item">
                                                    <input type="checkbox" id="model_deploy">
                                                    <label for="model_deploy">部署模型</label>
                                                </div>
                                            </div>
                                        </div>
                                        
                                        <div class="permission-group">
                                            <div class="permission-group-title">系统设置</div>
                                            <div class="checkbox-group">
                                                <div class="checkbox-item">
                                                    <input type="checkbox" id="sys_view">
                                                    <label for="sys_view">查看设置</label>
                                                </div>
                                                <div class="checkbox-item">
                                                    <input type="checkbox" id="sys_edit">
                                                    <label for="sys_edit">修改设置</label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                `);
                            }, 500);
                        } else if (action === '删除') {
                            if (confirm(`确定要删除${itemName}吗？此操作不可恢复！`)) {
                                showNotification(`已删除${itemName}`, 'success');
                            }
                        }
                    });
                }
            });
        });
        
        // 初始化下拉菜单
        function initDropdowns() {
            const dropdownTriggers = document.querySelectorAll('.dropdown-trigger');
            
            dropdownTriggers.forEach(trigger => {
                trigger.addEventListener('click', (e) => {
                    e.stopPropagation();
                    
                    const dropdown = trigger.closest('.dropdown');
                    const menu = dropdown.querySelector('.dropdown-menu');
                    
                    // 关闭其他下拉菜单
                    document.querySelectorAll('.dropdown-menu').forEach(item => {
                        if (item !== menu) {
                            item.classList.remove('show');
                        }
                    });
                    
                    // 切换当前下拉菜单
                    menu.classList.toggle('show');
                });
            });
            
            // 点击页面其他位置关闭下拉菜单
            document.addEventListener('click', () => {
                document.querySelectorAll('.dropdown-menu').forEach(menu => {
                    menu.classList.remove('show');
                });
            });
        }
        
        // 显示通知
        function showNotification(message, type = 'info') {
            // 检查是否存在通知容器
            let container = document.querySelector('.notification-container');
            if (!container) {
                container = document.createElement('div');
                container.className = 'notification-container';
                document.body.appendChild(container);
            }
            
            // 创建通知元素
            const notification = document.createElement('div');
            notification.className = `notification ${type}`;
            
            // 设置图标
            let icon = '';
            switch (type) {
                case 'success':
                    icon = '<i class="fas fa-check-circle"></i>';
                    break;
                case 'warning':
                    icon = '<i class="fas fa-exclamation-triangle"></i>';
                    break;
                case 'error':
                    icon = '<i class="fas fa-times-circle"></i>';
                    break;
                default:
                    icon = '<i class="fas fa-info-circle"></i>';
            }
            
            // 添加内容
            notification.innerHTML = `
                <div class="notification-icon">${icon}</div>
                <div class="notification-message">${message}</div>
                <div class="notification-close"><i class="fas fa-times"></i></div>
            `;
            
            // 添加到容器
            container.appendChild(notification);
            
            // 自动关闭
            setTimeout(() => {
                notification.classList.add('fade-out');
                setTimeout(() => {
                    notification.remove();
                }, 300);
            }, 3000);
            
            // 点击关闭
            notification.querySelector('.notification-close').addEventListener('click', () => {
                notification.classList.add('fade-out');
                setTimeout(() => {
                    notification.remove();
                }, 300);
            });
        }
        
        // 显示对话框
        function showDialog(title, content) {
            // 创建对话框遮罩
            const overlay = document.createElement('div');
            overlay.className = 'modal-overlay';
            document.body.appendChild(overlay);
            
            // 创建对话框
            const dialog = document.createElement('div');
            dialog.className = 'modal-dialog';
            
            dialog.innerHTML = `
                <div class="modal-header">
                    <div class="modal-title">${title}</div>
                    <button class="modal-close"><i class="fas fa-times"></i></button>
                </div>
                <div class="modal-content">
                    ${content}
                </div>
                <div class="modal-footer">
                    <button class="btn btn-secondary modal-cancel">取消</button>
                    <button class="btn btn-primary modal-confirm">确定</button>
                </div>
            `;
            
            document.body.appendChild(dialog);
            
            // 添加关闭事件
            const closeModal = () => {
                dialog.classList.add('fade-out');
                overlay.classList.add('fade-out');
                
                setTimeout(() => {
                    dialog.remove();
                    overlay.remove();
                }, 300);
            };
            
            // 绑定关闭按钮事件
            dialog.querySelector('.modal-close').addEventListener('click', closeModal);
            dialog.querySelector('.modal-cancel').addEventListener('click', closeModal);
            
            // 确认按钮事件
            dialog.querySelector('.modal-confirm').addEventListener('click', () => {
                showNotification('操作已成功保存', 'success');
                closeModal();
            });
            
            // 点击遮罩关闭
            overlay.addEventListener('click', closeModal);
            
            // 添加必要的样式
            const style = document.createElement('style');
            style.textContent = `
                .modal-overlay {
                    position: fixed;
                    top: 0;
                    left: 0;
                    right: 0;
                    bottom: 0;
                    background-color: rgba(0, 0, 0, 0.5);
                    z-index: 1000;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    animation: fade-in 0.3s ease-out;
                }
                
                .modal-dialog {
                    background-color: white;
                    border-radius: 8px;
                    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
                    width: 90%;
                    max-width: 500px;
                    max-height: 90vh;
                    display: flex;
                    flex-direction: column;
                    animation: slide-up 0.3s ease-out;
                    z-index: 1001;
                    position: fixed;
                    top: 50%;
                    left: 50%;
                    transform: translate(-50%, -50%);
                }
                
                .modal-header {
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    padding: 15px 20px;
                    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
                }
                
                .modal-title {
                    font-weight: 600;
                    font-size: 18px;
                    color: var(--primary-dark);
                }
                
                .modal-close {
                    background: none;
                    border: none;
                    cursor: pointer;
                    color: var(--gray);
                    font-size: 16px;
                    padding: 5px;
                }
                
                .modal-content {
                    padding: 20px;
                    overflow-y: auto;
                    max-height: calc(80vh - 130px);
                }
                
                .modal-footer {
                    padding: 15px 20px;
                    display: flex;
                    justify-content: flex-end;
                    gap: 10px;
                    border-top: 1px solid rgba(0, 0, 0, 0.1);
                }
                
                .form-group {
                    margin-bottom: 15px;
                }
                
                .form-group label {
                    display: block;
                    margin-bottom: 5px;
                    font-weight: 500;
                    color: var(--gray-dark);
                }
                
                .form-control {
                    width: 100%;
                    padding: 8px 12px;
                    border: 1px solid rgba(0, 0, 0, 0.1);
                    border-radius: 4px;
                    font-size: 14px;
                }
                
                textarea.form-control {
                    min-height: 100px;
                    resize: vertical;
                }
                
                .checkbox-group {
                    display: flex;
                    flex-direction: column;
                    gap: 8px;
                }
                
                .checkbox-item {
                    display: flex;
                    align-items: center;
                }
                
                .checkbox-item input {
                    margin-right: 8px;
                }
                
                .permission-group {
                    margin-bottom: 20px;
                }
                
                .permission-group-title {
                    font-weight: 600;
                    margin-bottom: 8px;
                    color: var(--primary-dark);
                }
                
                @keyframes fade-in {
                    from { opacity: 0; }
                    to { opacity: 1; }
                }
                
                @keyframes slide-up {
                    from { transform: translate(-50%, -40%); opacity: 0; }
                    to { transform: translate(-50%, -50%); opacity: 1; }
                }
                
                .fade-out {
                    animation: fade-out 0.3s ease-out forwards;
                }
                
                @keyframes fade-out {
                    from { opacity: 1; }
                    to { opacity: 0; }
                }
            `;
            
            document.head.appendChild(style);
        }
    </script>
</body>
</html> 